package com.eascs.dubbo.api.workflow;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.eascs.admin.api.workflow.WorkflowInfoService;
import com.eascs.admin.o2o.badloan.entity.O2oBadLoanPageVo;
import com.eascs.admin.o2o.badloan.service.O2oBadLoanService;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.admin.o2o.loan.service.O2oLoanUserService;
import com.eascs.admin.o2o.loan.service.O2oLoanapplyService;
import com.eascs.admin.o2o.specialInterview.entity.O2OSpecialInterview;
import com.eascs.admin.o2o.specialInterview.service.O2OSpecialInterviewService;
import com.eascs.admin.o2o.submitted.entity.O2oLoanSubmittedEntity;
import com.eascs.admin.o2o.submitted.serviceimpl.O2oLoanSubmittedServiceImple;
import com.eascs.app.dao.PageResult;
import com.eascs.brand.entity.O2oBrandEntity;
import com.eascs.brand.service.O2oBrandService;
import com.eascs.overdue.entity.O2oOverdueFormEntity;
import com.eascs.overdue.service.O2oOverdueService;
import com.eascs.partner.entity.DealerPartnerEntity;
import com.eascs.partner.service.JxsPartnerService;

@Service
public class WorkflowInfoServiceImpl implements WorkflowInfoService{

	@Autowired
	private JxsPartnerService jxsPartnerService;
	
	@Autowired
	private O2oBrandService brandService;
	
	@Autowired
	private O2oLoanSubmittedServiceImple o2oLoanSubmittedServiceImple;
	
	@Autowired
	private O2oLoanapplyService o2oLoanapplyService;
	
	@Autowired
	private O2oBadLoanService service;
	
	@Autowired
	O2oOverdueService o2oOverdueService;
	
	@Autowired
	O2OSpecialInterviewService o2OSpecialInterviewService;
	
	@Autowired
	private O2oLoanUserService loanService;
	
	@Override
	public DealerPartnerEntity getByReferId(String refer) {
		DealerPartnerEntity dealerPartnerEntity = jxsPartnerService.getEntityById(refer);
		return dealerPartnerEntity;
	}

	@Override
	public O2oBrandEntity getById(String id) {
		O2oBrandEntity brandEntity = brandService.getEntityById(id);
		return brandEntity;
	}

	@Override
	public O2oLoanSubmittedEntity getBySubmittedId(String referId) {
		O2oLoanSubmittedEntity o2oLoanSubmittedEntity = o2oLoanSubmittedServiceImple.getEntityById(referId);
		return o2oLoanSubmittedEntity;
	}

	@Override
	public O2oLoanapplyEntity getByO2oId(String loanapply) {
		O2oLoanapplyEntity o2oLoanapplyEntity = o2oLoanapplyService.findById(loanapply);
		return o2oLoanapplyEntity;
	}

	@Override
	public O2oLoanUserEntity getByO2oLoanUser(String loanapply, String loanId) {
		O2oLoanUserEntity o2oLoanUserEntity = o2oLoanapplyService.findLoanUserEntity(loanapply, loanId);
		return o2oLoanUserEntity;
	}

	@Override
	public PageResult<Object[]> getBadSpouseDate(String idCard, String mateIdCard) {
		O2oBadLoanPageVo vo = new O2oBadLoanPageVo();
		vo.setIdCard(idCard);
		vo.setSpouseIdCard(mateIdCard);
		return service.getBadLoanPage(vo);
	}

	@Override
	public PageResult<Object[]> getOverSpouseDate(String idCard, String mateIdCard) {
		O2oOverdueFormEntity entity =  new O2oOverdueFormEntity();
		entity.setIdCard(idCard);
		entity.setSpouseIdCard(mateIdCard);
		return o2oOverdueService.getO2oOverduePage(entity);
	}

	@Override
	public O2OSpecialInterview getSpecialEntity(String loanapply) {
		return o2OSpecialInterviewService.queryEntity(loanapply);
	}

	@Override
	public List<O2oLoanUserEntity> getTdWord(String loanapply) {
		return loanService.queryUsersByLoanapplyNo(loanapply);
	}

}
